package stdying.handyweibo.injection.restmodule;

import com.squareup.okhttp.OkHttpClient;

import java.util.concurrent.TimeUnit;

import dagger.Module;
import dagger.Provides;
import stdying.handyweibo.injection.PreActivity;
import stdying.handyweibo.rest.RestConfig;

/**
 * Description: OkHttpModule
 * Author: liulili
 * Created: 2015-11-24
 */
@Module
public class OkHttpModule {

    /**
     * 提供okhttpclient
     * @return
     */
    @Provides
    @PreActivity
    OkHttpClient provideOkHttpClient(){
        OkHttpClient okHttpClient = new OkHttpClient();
        //超时设置
        okHttpClient.setConnectTimeout(RestConfig.CONN_TIME_OUT, TimeUnit.MILLISECONDS);
        okHttpClient.setReadTimeout(RestConfig.READ_TIME_OUT,TimeUnit.MILLISECONDS);
       //还可以添加拦截器
        return okHttpClient;
    }


}
